<?php
session_start(); // 必须放在最顶部
// 未登录则跳回登录页
if (!isset($_SESSION['admin_logged_in']) || !$_SESSION['admin_logged_in']) {
    echo "<script>alert('请先登录'); window.location.href='admin.html';</script>";
    exit;
}
$admin_name = $_SESSION['admin_username'] ?? '管理员'; // 读取已存储的用户名
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>管理员后台 - FitPeak</title>
  <script src="https://cdn.tailwindcss.com"></script>
<!-- 其他页面也替换为 5.x 版本 -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
  
  <script>
    tailwind.config = {
      theme: {
        extend: {
          colors: {
            primary: '#165DFF',
            dark: '#1F2937'
          }
        }
      }
    }
  </script>
</head>
<body class="bg-gray-100 min-h-screen">
  <!-- 顶部导航栏 -->
  <header class="bg-dark text-white shadow-md">
    <div class="container mx-auto px-4 py-3 flex justify-between items-center">
      <div class="flex items-center">
        <i class="fa fa-shield-alt text-2xl mr-2"></i>
        <h1 class="text-xl font-bold">FitPeak 管理员后台</h1>
      </div>
       <div class="flex items-center">
      <!-- 直接输出 Session 中的用户名 -->
      <span class="mr-4"><?php echo $admin_name; ?></span>
      <a href="admin_logout.php" class="text-gray-300 hover:text-white transition-colors">退出登录</a>
    </div>
    </div>
  </header>
  
  <!-- 主要内容区 -->
  <main class="container mx-auto px-4 py-8">
    <div class="mb-8">
      <h2 class="text-2xl font-bold text-gray-800">欢迎使用管理员后台</h2>
      <p class="text-gray-600 mt-2">在这里可以管理用户和系统设置</p>
    </div>
    
    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
      <!-- 用户管理卡片 -->
      <div class="bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow">
        <div class="flex items-center mb-4">
          <div class="w-12 h-12 bg-primary/10 rounded-full flex items-center justify-center mr-4">
            <i class="fa fa-users text-primary text-xl"></i>
          </div>
          <h3 class="text-lg font-semibold">用户管理</h3>
        </div>
        <p class="text-gray-600 mb-4">查看和管理所有注册用户</p>
        <a href="admin_users.html" class="text-primary hover:text-primary/80 flex items-center">
          <span>查看用户列表</span>
          <i class="fa fa-arrow-right ml-2"></i>
        </a>
      </div>
      
      <!-- 数据统计卡片 -->
      <div class="bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow">
        <div class="flex items-center mb-4">
          <div class="w-12 h-12 bg-primary/10 rounded-full flex items-center justify-center mr-4">
            <i class="fas fa-chart-bar text-primary text-xl"></i>
          </div>
          <h3 class="text-lg font-semibold">数据统计</h3>
        </div>
        <p class="text-gray-600 mb-4">查看平台用户增长和活动数据</p>
        <a href="admin_stats.html" class="text-primary hover:text-primary/80 flex items-center">
          <span>查看统计数据</span>
          <i class="fa fa-arrow-right ml-2"></i>
        </a>
      </div>
      
      <!-- 系统设置卡片 -->
      <div class="bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow">
        <div class="flex items-center mb-4">
          <div class="w-12 h-12 bg-primary/10 rounded-full flex items-center justify-center mr-4">
            <i class="fa fa-cog text-primary text-xl"></i>
          </div>
          <h3 class="text-lg font-semibold">系统设置</h3>
        </div>
        <p class="text-gray-600 mb-4">配置平台参数和管理选项</p>
        <a href="admin_settings.html" class="text-primary hover:text-primary/80 flex items-center">
          <span>进入设置</span>
          <i class="fa fa-arrow-right ml-2"></i>
        </a>
      </div>
    </div>
  </main>
  
  
</body>
</html>
